package com.ss.android.wenda.a;

import com.bytedance.retrofit2.Call;
import com.bytedance.retrofit2.Callback;
import com.ss.android.topic.e.a.a;
import com.ss.android.wenda.IWendaApi;
import com.ss.android.wenda.entity.AnswerFoldReasonEntity;
import com.ss.android.wenda.entity.ConcernTagEntity;
import com.ss.android.wenda.entity.QuestionDescEntity;
import com.ss.android.wenda.entity.QuestionEntity;
import com.ss.android.wenda.entity.response.WDChannelRecommendStructEntity;
import com.ss.android.wenda.entity.response.WDQuestionBrowResponseEntity;
import com.ss.android.wenda.model.AnswerFoldReason;
import com.ss.android.wenda.model.ConcernTag;
import com.ss.android.wenda.model.Question;
import com.ss.android.wenda.model.QuestionDesc;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

public final class d extends a {
    public d(Map arg2, Callback arg3) {
        super("/wenda/v1/question/brow/", arg2, arg3);
    }

    public final Call a(String arg5, Map arg6) {
        Map v1 = null;
        Object v0 = com.ss.android.topic.aa.a("http://ib.snssdk.com", IWendaApi.class);
        Call v0_1 = v0 != null ? ((IWendaApi)v0).niceAnswerPage("POST", arg5, v1, d.a(arg6)) : ((Call)v1);
        return v0_1;
    }

    public final Object a(Object arg11) {
        com.ss.android.wenda.model.response.b v1_2 = null;
        com.ss.android.wenda.model.response.a v1_1 = null;
        List v0_6;
        ConcernTag v0_5;
        AnswerFoldReason v0_2;
        QuestionDesc v0_1;
        Question v0;
        Object v1 = null;
        if(arg11 != null) {
            com.ss.android.wenda.model.response.b v4 = new com.ss.android.wenda.model.response.b();
            v4.a = ((WDQuestionBrowResponseEntity)arg11).err_no;
            v4.b = ((WDQuestionBrowResponseEntity)arg11).err_tips;
            v4.d = android.support.design.a.b(((WDQuestionBrowResponseEntity)arg11).ans_list);
            v4.f = ((WDQuestionBrowResponseEntity)arg11).has_more;
            v4.e = ((WDQuestionBrowResponseEntity)arg11).offset;
            QuestionEntity v6 = ((WDQuestionBrowResponseEntity)arg11).question;
            if(v6 == null) {
                v0 = ((Question)v1);
            } else {
                Question v3 = new Question();
                v3.mQid = v6.qid;
                v3.mTitle = v6.title;
                v3.mCreateTime = v6.create_time;
                v3.mNiceAnswerCount = v6.nice_ans_count;
                v3.mNormalAnswerCount = v6.normal_ans_count;
                QuestionDescEntity v2 = v6.content;
                if(v2 == null) {
                    v0_1 = ((QuestionDesc)v1);
                }
                else {
                    v0_1 = new QuestionDesc();
                    if(v2.text != null) {
                        v2.text = v2.text.trim();
                    }

                    v0_1.mContent = v2.text;
                    v0_1.mLargeImages = v2.large_image_list;
                    v0_1.mThumbImages = v2.thumb_image_list;
                }

                v3.mQuestionDesc = v0_1;
                v3.mUser = android.support.design.a.a(v6.user);
                v3.mShareData = android.support.design.a.a(v6.share_data);
                AnswerFoldReasonEntity v2_1 = v6.fold_reason;
                if(v2_1 == null) {
                    v0_2 = ((AnswerFoldReason)v1);
                }
                else {
                    v0_2 = new AnswerFoldReason();
                    v0_2.mOpenUrl = v2_1.open_url;
                    v0_2.mTitle = v2_1.title;
                }

                v3.mAnswerFoldReason = v0_2;
                v3.mStatus = v6.status;
                v0_6 = v6.concern_tag_list;
                if(v0_6 == null) {
                    v0_6 = Collections.emptyList();
                } else {
                    ArrayList v2_2 = new ArrayList();
                    Iterator v7 = v0_6.iterator();
                    while(v7.hasNext()) {
                        Object v0_4 = v7.next();
                        if(v0_4 == null) {
                            v0_5 = ((ConcernTag)v1);
                        }
                        else {
                            ConcernTag v5 = new ConcernTag();
                            v5.mCid = ((ConcernTagEntity)v0_4).concern_id;
                            v5.mName = ((ConcernTagEntity)v0_4).name;
                            v5.mSchema = ((ConcernTagEntity)v0_4).schema;
                            v0_5 = v5;
                        }

                        if(v0_5 == null) {
                            continue;
                        }

                        ((List)v2_2).add(v0_5);
                    }

                    v0_6 = v2_2;
                }

                v3.mConcernTags = ((List)v0_6);
                v3.mFollowCount = v6.follow_count;
                v3.mIsFollow = v6.is_follow;
                v3.mCanDelete = v6.can_delete;
                v3.mCanEdit = v6.can_edit;
                v3.mShowDelete = v6.show_delete;
                v3.mShowEdit = v6.show_edit;
                v0 = v3;
            }

            v4.c = v0;
            WDChannelRecommendStructEntity v0_7 = ((WDQuestionBrowResponseEntity)arg11).channel_data;
            if(v0_7 != null) {
                v1_1 = new com.ss.android.wenda.model.response.a();
                v1_1.c = v0_7.open_url;
                v1_1.a = v0_7.pos;
                v1_1.b = v0_7.text;
            }

            v4.g = v1_1;
            v1_2 = v4;
        }

        return v1_2;
    }
}

